import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import operatebag.*;
import people.User;

public class operatepage extends JFrame {
    private JMenuBar menuBar;
    private JMenu student_Management;
    private JMenu score_Management;
    private JMenu personal_Management;
    private JMenu other;
    private JMenuItem addstudent;
    private JMenuItem changestudent;
    private JMenuItem searchstudent;
    private JMenuItem detectstudent;
    private JMenuItem scoreadd;
    private JMenuItem scorechange;
    private JMenuItem mimachange;
    private JMenuItem logout;
    private JMenuItem about;
    private JFrame jf;
    private String username,password;

    public operatepage(String s1,String s2){
        username=s1;
        password=s2;
        setTitle("学生成绩管理系统");
        setBounds(300,100,800,700);
        setResizable(false);
        setDefaultCloseOperation(HIDE_ON_CLOSE);
        jf=this;
        menuBar = new JMenuBar();
        this.setJMenuBar(menuBar);
        student_Management=new JMenu("学生管理");
        score_Management=new JMenu("学生精准查询");
        personal_Management=new JMenu("账号信息管理");
        other=new JMenu("其他");
        menuBar.add(student_Management);
        menuBar.add(score_Management);
        menuBar.add(personal_Management);
        menuBar.add(other);
        //添加学生
        addstudent=new JMenuItem("添加学生");
        student_Management.add(addstudent);
        addstudent.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    new addstudent();
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            }
        });

        //修改学生
        changestudent=new JMenuItem("修改学生");
        student_Management.add(changestudent);
        changestudent.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new changstudent();
            }
        });

        //查询学生
        searchstudent=new JMenuItem("显示所有学生");
        student_Management.add(searchstudent);
        searchstudent.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    new showstudent();
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            }
        });
        //删除学生
        detectstudent=new JMenuItem("删除学生");
        student_Management.add(detectstudent);
        detectstudent.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                try {
                    new showstudent();
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
                new detestudent();
            }
        });

        //成绩添加管理
        scoreadd=new JMenuItem("姓名查找");
        score_Management.add(scoreadd);
        scoreadd.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int u=1;
                new namefind(u);
            }
        });
        //成绩修改
        scorechange=new JMenuItem("学号查找");
        score_Management.add(scorechange);
        scorechange.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int u=0;
                new namefind(u);
            }
        });

        //改密码
        mimachange=new JMenuItem("修改密码");
        personal_Management.add(mimachange);
        mimachange.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                User use=new User();
                use.setId(username);
                use.setPassword(password);
                changmima ch=new changmima(use);
            }
        });



        logout=new JMenuItem("退出");
        other.add(logout);
        logout.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new startpage();
                jf.dispose();
            }
        });

        about=new JMenuItem("关于我们");
        other.add(about);
        about.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new whowe();
            }
        });
        setVisible(true);
    }
}
